﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace WinFormsMVC
{
    public class ViewDataDictionary : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
    {
        IDictionary<string, object> objects = new Dictionary<string, object>();

        public IEnumerator GetEnumerator()
        {
            return objects.GetEnumerator();
        }

        public void Add(KeyValuePair<string, object> item)
        {
            objects.Add(item);
        }

        public void Clear()
        {
            objects.Clear();
        }

        public bool Contains(KeyValuePair<string, object> item)
        {
            return objects.Contains(item);
        }

        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
        {
            objects.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get
            {
                return objects.Count();
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return objects.IsReadOnly;
            }
        }

        public bool Remove(KeyValuePair<string, object> item)
        {
            return objects.Remove(item);
        }

        IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
        {
            return objects.GetEnumerator();
        }

        public void Add(string key, object value)
        {
            objects.Add(key, value);
        }

        public bool ContainsKey(string key)
        {
            return objects.ContainsKey(key);
        }

        public ICollection<string> Keys
        {
            get
            {
                return objects.Keys;
            }
        }

        public bool Remove(string key)
        {
            return objects.Remove(key);
        }

        public bool TryGetValue(string key, out object value)
        {
            return objects.TryGetValue(key, out value);
        }

        public ICollection<object> Values
        {
            get
            {
                return objects.Values;
            }
        }

        public object this[string key]
        {
            get
            {
                return objects[key];
            }
            set
            {
                objects[key] = value;
            }
        }
    }
}
